import { EntitySchema } from '@mikro-orm/core';

export class LeOrderAfter {
  id!: string;
  orderSn!: string;
  afterSn!: string;
  orderGoodsId!: string;
  UID!: string;
  type: boolean = false;
  source!: string;
  returnNumber: number = 1;
  returnAmount!: string;
  returnFreight!: string;
  images?: string;
  status: number = 100;
  returnAddress?: string;
  userNote?: string;
  userFreightInfo?: string;
  merchantNote?: string;
  merchantFreightInfo?: string;
  merchantId!: string;
  AppID!: string;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isDeleted: boolean = false;
  returnReason?: string;
  process?: string;
  refuseReason?: string;
  actualRefund?: string;
  auditTime?: string;
  returnTime?: string;
  exchangeTime?: string;
  refuseTime?: string;
  finishTime?: string;
  salesexchangeTime?: string;
  returnSn?: string;
  secondRefuseReason?: string;
  returnScore!: string;
  actualScore?: string;
  orderType?: string;
  returnScoreType?: boolean = false;
}

export const LeOrderAfterSchema = new EntitySchema({
  class: LeOrderAfter,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    orderSn: { type: 'string', length: 50, index: '订单编号' },
    afterSn: { type: 'string', length: 50, index: '售后编号' },
    orderGoodsId: { type: 'string', columnType: 'bigint', index: '订单商品id' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', index: '用户id' },
    type: { type: 'boolean', default: false },
    source: { type: 'string', length: 50 },
    returnNumber: { type: 'number', default: 1 },
    returnAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    returnFreight: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    images: { type: 'string', columnType: 'text', nullable: true },
    status: { type: 'number', columnType: 'smallint', default: 100 },
    returnAddress: { type: 'string', columnType: 'text', nullable: true },
    userNote: { type: 'string', length: 255, nullable: true },
    userFreightInfo: { type: 'string', columnType: 'text', nullable: true },
    merchantNote: { type: 'string', length: 255, nullable: true },
    merchantFreightInfo: { type: 'string', columnType: 'text', nullable: true },
    merchantId: { type: 'string', columnType: 'bigint', index: '商户id' },
    AppID: { type: 'string', fieldName: 'AppID', length: 50, index: '应用id' },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isDeleted: { type: 'boolean', default: false },
    returnReason: { type: 'string', length: 255, nullable: true },
    process: { type: 'string', columnType: 'text', nullable: true },
    refuseReason: { type: 'string', length: 255, nullable: true },
    actualRefund: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    auditTime: { type: 'string', columnType: 'bigint', nullable: true },
    returnTime: { type: 'string', columnType: 'bigint', nullable: true },
    exchangeTime: { type: 'string', columnType: 'bigint', nullable: true },
    refuseTime: { type: 'string', columnType: 'bigint', nullable: true },
    finishTime: { type: 'string', columnType: 'bigint', nullable: true },
    salesexchangeTime: { type: 'string', columnType: 'bigint', nullable: true },
    returnSn: { type: 'string', length: 50, nullable: true },
    secondRefuseReason: { type: 'string', length: 255, nullable: true },
    returnScore: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    actualScore: { type: 'string', columnType: 'bigint', nullable: true },
    orderType: { type: 'string', length: 255, nullable: true, default: 'base' },
    returnScoreType: { type: 'boolean', nullable: true, default: false },
  },
});
